home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / Information / CSMP Digest / volume 1 / csmp-v1-143.txt < prev    next >
Encoding:
Text File  |  1994-12-08  |  32.2 KB  |  876 lines  |  [TEXT/R*ch]

  1. C.S.M.P. Digest             Fri, 17 Jul 92       Volume 1 : Issue 143
  2.  
  3. Today's Topics:
  4.  
  5.     PICS format
  6.     Coercing color icons to a new color palette
  7.     Temporary Memory in a CDEV
  8.     ?? Cobol Compiler for the MAC ???
  9.     How do you disable the disk cache?
  10.     Booleans & SIZE in THINK C (not related)
  11.     Sys 7 popupMenuCDEFProc in 6.0.7
  12.     MPW shell crashes with Bus Error
  13.     PopUp menus crash bigtime on Mac II and IIFX machines. Why?
  14.  
  15.  
  16.  
  17. The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly.
  18.  
  19. The digest is a collection of article threads from the internet newsgroup
  20. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  21. regularly and want an archive of the discussions.  If you don't know what a
  22. newsgroup is, you probably don't have access to it.  Ask your systems
  23. administrator(s) for details.  (This means you can't post questions to the
  24. digest.)
  25.  
  26. Each issue of the digest contains one or more sets of articles (called
  27. threads), with each set corresponding to a 'discussion' of a particular
  28. subject.  The articles are not edited; all articles included in this digest
  29. are in their original posted form (as received by our news server at
  30. cs.uoregon.edu).  Article threads are not added to the digest until the last
  31. article added to the thread is at least one month old (this is to ensure that
  32. the thread is dead before adding it to the digest).  Article threads that
  33. consist of only one message are generally not included in the digest.
  34.  
  35. The entire digest is available for anonymous ftp from ftp.cs.uoregon.edu
  36. [128.223.8.8] in the directory /pub/mac/csmp-digest.  The most recent issues
  37. are available from sumex-aim.stanford.edu [36.44.0.6] in the directory
  38. /info-mac/digest/csmp.  If you don't have ftp capability, the sumex archive
  39. has a mail server; send a message with the text '$MACarch help' (no quotes)
  40. to LISTSERV@ricevm1.rice.edu for more information.
  41.  
  42. The digest is also available via email.  Just send a note saying that you
  43. want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will
  44. automatically receive each new issue as it is created.  Sorry, back issues
  45. are not available through the mailing list.
  46.  
  47. Send administrative mail to mkelly@cs.uoregon.edu.
  48.  
  49.  
  50. -------------------------------------------------------
  51.  
  52. From: D.Rees@cs.ucl.ac.uk (David Rees)
  53. Subject: PICS format
  54. Date: 12 Jun 92 15:08:32 GMT
  55.  
  56. Does anyone know the format for PICS files, or any archive where
  57. documentation may be found? I'm aware that PICS are a sequence
  58. of PICT images, stored as separate resource instances, but I dont know
  59. what (if any) extra information is needed. eg. is there another
  60. resource with global information, such as number of PICTs...,
  61. and is there any logic to resource number and ordering?
  62.  
  63. thanks in adavance,
  64.  
  65. David Rees.
  66.  
  67. +++++++++++++++++++++++++++
  68.  
  69. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  70. Date: 15 Jun 92 13:17:29 +1200
  71. Organization: University of Waikato, Hamilton, New Zealand
  72.  
  73. In article <2660@ucl-cs.uucp>, D.Rees@cs.ucl.ac.uk (David Rees) asks about
  74. the format of PICS files.
  75.  
  76. I got my information from an article in MacTutor magazine. It's quite simple,
  77. really: the file type must be PICS, and the image frames are a sequence of
  78. PICT resources, which must be numbered sequentially (with no gaps) from 128.
  79. You can tell you've reached the end of the sequence when you call
  80. Get1Resource('PICT', NextFrameResID) and don't get anything back.
  81.  
  82. The first image frame (the PICT with ID 128) must be present; its bounding box
  83. defines the bounds of the entire movie. Subsequent frames may have different
  84. (smaller) bounding boxes. The idea is that subsequent frames are displayed by
  85. drawing them on top of previous frames using the same coordinate origin, so
  86. you can save space (and drawing time) by leaving out portions of the image
  87. that don't change from subsequent frames. But you don't *have* to do this:
  88. the only requirement is that all frames from the second one onwards don't
  89. extend outside the bounding box of the first frame.
  90.  
  91. You can have an INFO resource, with ID 128, but that's optional. If present,
  92. it contains a structure like this:
  93.  
  94.     BWColor (word):
  95.         0 for b/w, 1 for colour/greyscale pictures.
  96.     PixelDepth (word):
  97.         bits per pixel at which the pictures look best (1/2/4/8/16/32).
  98.            Playback speed (signed word):
  99.         a positive number indicates frames per second
  100.         a negative number indicates seconds per frame
  101.     Version (word):
  102.         Currently 0
  103.     Creator (OSType longword):
  104.         I think this may be used to identify vendor-specific
  105.         extensions of the INFO structure.
  106.     LargestPictureSize (longword):
  107.         The size in bytes of the largest PICT resource. You can
  108.         set this to 0 if you can't be bothered calculating it.
  109.  
  110. That's it.
  111.  
  112. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  113. Computer Services Dept                     fax: +64-7-838-4066
  114. University of Waikato            electric mail: ldo@waikato.ac.nz
  115. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  116.  
  117. ---------------------------
  118.  
  119. From: ejohnson@sparc3.cs.uiuc.edu (Eric E Johnson)
  120. Subject: Coercing color icons to a new color palette
  121. Organization: University of Illinois at Urbana-Champaign
  122. Date: Sun, 14 Jun 1992 02:13:40 GMT
  123.  
  124. Last week, I had posted a question about fast drawing in QuickDraw.  I
  125. got a lot of responses (which was helpful), but now I have another
  126. question.
  127.  
  128. I bought Inside Macintosh VI and I have a hard copy of Technical Note
  129. #120.  So here's the problem.  I load in a color icon resource (cicn).
  130. I build my off screen gWorld, and fill it in with a light blue color.  I
  131. then copy the entire thing to the screen.  This makes it to the screen
  132. just fine.
  133.  
  134. But, when I try to draw my color icon to the off screen world, and then
  135. copy everything to the screen, the icon is obviously mangled.  I had
  136. figured that this would be the case, because the color palettes didn't
  137. match, as I had expected.  But, I thought that the overall shape and
  138. features of the icon would still appear, just with bad colors.
  139.  
  140. I figure that there are two possibilities for this problem: color
  141. palettes that don't match (which is true, they don't) and/or that I
  142. never provide copybits with the right pointer to the color icon to begin
  143. with.  Here's the code.  Its short, and I would appreciate any advice.
  144.  
  145.     GWorldPtr    colorPort;
  146.     CGrafPtr    savedPort;
  147.     GDHandle    savedDevice;
  148.     CTabHandle    offColors;
  149.     Rect        offRect, circleRect;
  150.     Rect        iconRect = {0,0,25,25};
  151.     Rect        destRect = {100,100,125,125};
  152.     short        count;
  153.     RGBColor    aColor;
  154.     OSErr        error;
  155.     CIconHandle    MyTerrain;
  156.     
  157.     SetRect(&offRect, 0, 0,325, 325);    /* Create off screen rect */
  158.     MyTerrain = GetCIcon(128);        /* Read in icon */
  159.     offColors = GetCTable(rColorClut);    /* Read in my clut */
  160.     GetGWorld(&savedPort, &savedDevice);    /* Save the current device */
  161.     error = NewGWorld(&colorPort,kOffDepth, &offRect, 0, nil, 0);
  162.     if (error == noErr)
  163.         {
  164.         SetGWorld(colorPort,nil);
  165.             aColor.red = 0x2CDF;aColor.blue = 0x6000;aColor.green = 0x2000;
  166.         RGBBackColor(&aColor);
  167.         LockPixels(colorPort->portPixMap);
  168.         EraseRect(&colorPort->portRect);
  169.  
  170.     /* This is the copybits line that is in question */
  171.  
  172.         CopyBits(&(**MyTerrain).iconPMap,&((GrafPtr)
  173.              colorPort)->portBits,&iconRect,&destRect,srcCopy,nil);
  174.         UnlockPixels(colorPort->portPixMap);
  175.         SetGWorld(savedPort, savedDevice);
  176.         CopyBits(&((GrafPtr) colorPort)->portBits, &((GrafPtr)
  177. savedPort)->portBits, &colorPort->portRect, &colorPort->portRect,
  178. srcCopy, nil);
  179.         DisposeGWorld(colorPort);
  180.         }
  181.  
  182.  
  183. - -- 
  184. Eric Johnson               | "The American Republic will endure until the day
  185. ejohnson@suna0.cs.uiuc.edu |  Congress discovers that it can bribe the public
  186. eej37047@uxa.cso.uiuc.edu  |  with the public's money" - Alexis de Toucqueville
  187.  
  188. +++++++++++++++++++++++++++
  189.  
  190. From: lari@strauss.cs.unc.edu (Humayun Lari)
  191. Date: 14 Jun 92 22:01:06 GMT
  192. Organization: University of North Carolina, Chapel Hill
  193.  
  194. In article <1992Jun14.021340.17341@sunb10.cs.uiuc.edu> ejohnson@sparc3.cs.uiuc.edu (Eric E Johnson) writes:
  195.  
  196. >when I try to draw my color icon to the off screen world, and then
  197. >copy everything to the screen, the icon is obviously mangled.  I had
  198. >figured that this would be the case, because the color palettes didn't
  199. >match, as I had expected.  But, I thought that the overall shape and
  200. >features of the icon would still appear, just with bad colors.
  201. [deleted]
  202. >       error = NewGWorld(&colorPort,kOffDepth, &offRect, 0, nil, 0);
  203.  
  204. If your kOffDepth is non-zero and you want to use a specific color table, you
  205. should pass the color table to NewGWorld -- take another look at the definition
  206. in IM VI. If you want speed, set kOffDepth to 0 and pass the global coordinates
  207. of the screen rectangle you'll be drawing in (such as the content rectangle
  208. of a window). NewGWorld will then use the characteristics of the "best"
  209. gdevice that intersects the given rectangle.
  210.  
  211. [deleted]
  212. >               SetGWorld(colorPort,nil);
  213. >               aColor.red = 0x2CDF;aColor.blue = 0x6000;aColor.green = 0x2000;
  214. >               RGBBackColor(&aColor);
  215. >               LockPixels(colorPort->portPixMap);
  216. >               EraseRect(&colorPort->portRect);
  217.  
  218. The problem here is that CopyBits colorizes the pixmap (or bitmap, for that
  219. matter) it is copying, using the current foreground and background colors.
  220. This is actually a feature :-). Make sure the foreground color is black and
  221. the background color is white before using CopyBits. Better yet, write
  222. a little procedure that resets the colors to black and white, and call it
  223. right before you call CopyBits.
  224.  
  225. >
  226. >               CopyBits(&(**MyTerrain).iconPMap,&((GrafPtr)
  227. >                        colorPort)->portBits,&iconRect,&destRect,srcCopy,nil);
  228. [deleted]
  229. >
  230. >--
  231. >Eric Johnson               | "The American Republic will endure until the day
  232. >ejohnson@suna0.cs.uiuc.edu |  Congress discovers that it can bribe the public
  233. >eej37047@uxa.cso.uiuc.edu  |  with the public's money" - Alexis de Toucqueville
  234.  
  235. Humayun Lari
  236. (lari@cs.unc.edu)
  237.  
  238. ---------------------------
  239.  
  240. From: 3jean@maas-neotek.arc.nasa.gov (E.T.A.)
  241. Subject: Temporary Memory in a CDEV
  242. Organization: NASA Ames Research Center
  243. Date: Sun, 14 Jun 1992 21:07:09 GMT
  244.  
  245. I'm writing a CDEV and running it under System 7. I've been having
  246. problems with crashes and just now I realized that the stack is
  247. colliding with the CDEV's heap since I allocate a large amount of
  248. memory in the CDEV's application heap.
  249.  
  250. 1. Is there a way to increase the heap size of my CDEV ?
  251.  
  252. 2. Or is there a way to get a fairly large amount of temporary
  253. memory from Multifinder that I could use ?
  254.  
  255. (I remember a Technical Note about Multifinder temporary memory but I
  256. can't seem to find it right now. Isn't the temporary memory from
  257. Multifinder limited -- i.e. handles are fake handles?)
  258.  
  259. Thanks in advance for any help you may be able to give on this.
  260.  
  261. - -Eric Anderson
  262. 3jean@maas-neotek.arc.nasa.gov
  263.  
  264. +++++++++++++++++++++++++++
  265.  
  266. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  267. Date: 15 Jun 92 00:14:56 GMT
  268. Organization: U. C. Berkeley Open Computing Facility
  269.  
  270. > 1. Is there a way to increase the heap size of my CDEV ? 
  271. > 2. Or is there a way to get a fairly large amount of temporary memory
  272. > from Multifinder that I could use ?
  273.  
  274. 1)  First of all, your CDEV does not have its own heap.  It runs in the Finder's heap under system 7 and in the DA Handler's heap under 6.x with multifinder.  So you are already out some stack space the Finder is using.  I make it a point
  275. never to use more than 1K or so of stack space.  Instead, call NewPtr or NewHandle to allocate the amount of memory you need in the heap.  You will be responsible for dispos'ing of it when you are through.
  276.  
  277. 2)  There is a way, and it is documented in a technote somewhere (or maybe it's in Volume VI, I don't know).  I do know that temp memory should only be used for a short amount of time and returned to multifinder as soon as possible.  Since your control panel may be open for any length of time, using temporary memory may make it impossible for the user to launch a new application.
  278.  
  279. - -Elizabeth
  280.  
  281. +++++++++++++++++++++++++++
  282.  
  283. From: ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  284. Date: 15 Jun 92 18:01:11 +1200
  285. Organization: University of Waikato, Hamilton, New Zealand
  286.  
  287. In article <11gne0INNt6e@agate.berkeley.edu>, ewylie@ocf.berkeley.edu
  288. (Elizabeth Wylie) writes:
  289. >> 1. Is there a way to increase the heap size of my CDEV ?
  290. >>
  291. >> 2. Or is there a way to get a fairly large amount of temporary memory
  292. >> from Multifinder that I could use ?
  293. >
  294. > 1)  First of all, your CDEV does not have its own heap.  It runs in the
  295. > Finder's heap under system 7 and in the DA Handler's heap under 6.x with
  296. > multifinder.
  297.  
  298. The part about System 7 is correct. Under System 6, control panels run
  299. within the context of the Control Panel DA, so their heap context is the
  300. same as for DAs under System 7 or MultiFinder: that is, the current heap is
  301. the system heap.
  302.  
  303. >  So you are already out some stack space the Finder is using.
  304. > I make it a point never to use more than 1K or so of stack space.  Instead,
  305. > call NewPtr or NewHandle to allocate the amount of memory you need in the
  306. > heap.  You will be responsible for dispos'ing of it when you are through.
  307.  
  308. I just did a quick check with a control panel I wrote a long time ago, and
  309. it turns out that Finder 7 sets the current heap to the system heap before
  310. passing control to a control panel. Thus you shouldn't have to take special
  311. action to allocate large or small amounts of memory: just call NewPtr and
  312. NewHandle like you would normally expect to. Just remember that you *must*
  313. dispose of blocks that you've finished with, or they will stay allocated until
  314. the machine is shut down.
  315.  
  316. > 2)  There is a way, and it is documented in a technote somewhere (or maybe
  317. > it's in Volume VI, I don't know).  I do know that temp memory should only be
  318. > used for a short amount of time and returned to multifinder as soon as
  319. > possible.  Since your control panel may be open for any length of time,
  320. > using temporary memory may make it impossible for the user to launch a new
  321. > application.
  322.  
  323. I don't think that *allocating* the temporary memory itself is going to cause
  324. much fragmentation, though *locking* it certainly will.
  325.  
  326. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  327. Computer Services Dept                     fax: +64-7-838-4066
  328. University of Waikato            electric mail: ldo@waikato.ac.nz
  329. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  330.  
  331. ---------------------------
  332.  
  333. From: day_kevran@tandem.tandem.com (Kevran Day )
  334. Subject: ?? Cobol Compiler for the MAC ???
  335. Organization: Tandem Computers, Inc.
  336. Date: Wed, 3 Jun 1992 19:55:14 GMT
  337.  
  338. Does anyone know of a Cobol Compiler for the MAC?  APDA Catalog doesn't have one listed,
  339. but hopefully that doesn't mean one doesn't exist!
  340.  
  341. - - Kevran Day 
  342.  
  343.  
  344. +++++++++++++++++++++++++++
  345.  
  346. From: owen@lloyd.Camex.COM (Owen Hartnett)
  347. Organization: Camex Inc., Boston MA
  348. Date: Mon, 15 Jun 1992 08:26:51 EDT
  349.  
  350. In article <1992Jun3.195514.6031@tandem.com> day_kevran@tandem.tandem.com (Kevran Day ) writes:
  351. >Does anyone know of a Cobol Compiler for the MAC?  APDA Catalog doesn't have one listed,
  352. >but hopefully that doesn't mean one doesn't exist!
  353. >
  354. >- Kevran Day 
  355. >
  356.  
  357. This one runs under AUX only! 
  358.  
  359. Acucobol-85, requires PMMU Mac, 4MB Ram and hard disk drive.
  360. $400 to $2000 retail
  361.  
  362. Acucobol, Inc.
  363. 7950 Silverton Avenue, Ste. 201
  364. San Diego, CA 92126
  365.  
  366. (619) 689-7220
  367. (619) 566-3071 (fax)
  368.  
  369. Information from the 1992 macintosh Product Registry.  I don't know
  370. anything about the compiler.
  371.  
  372. - -Owen
  373.  
  374.  
  375. ---------------------------
  376.  
  377. From: oster@well.sf.ca.us (David Phillip Oster)
  378. Subject: How do you disable the disk cache?
  379. Organization: Whole Earth 'Lectronic Link
  380. Date: Sat, 13 Jun 1992 03:52:24 GMT
  381.  
  382. How do you disable the cacheing of disk i/o to ram via program
  383. control?
  384.  
  385. I remember reading that the Finder would turn off disk cacheing when it
  386. did a file copy, because the copy would just flush anything useful in
  387. the cache. The same article that said this described a way to turn the
  388. cache on and off and query its current state so it could be restored,
  389. but I don't remember where that article was. I searched the current
  390. Developer's CD for "disk cache" without finding it.
  391.  
  392. I have a real reason, not just superstitious fear of the cache:  I'm
  393. asking because I've written a driver for a SCSI scanner. If the cache
  394. is too large, then when the application that calls the driver writes a
  395. buffer of scan data to disk, the disk i/o takes so long that the
  396. scanner hardware times out and locks up.
  397.  
  398. +++++++++++++++++++++++++++
  399.  
  400. From: keith@taligent.com (Keith Rollin)
  401. Date: 15 Jun 92 20:13:34 GMT
  402. Organization: Taligent
  403.  
  404. In article <1992Jun13.035224.9474@well.sf.ca.us>, oster@well.sf.ca.us (David
  405. Phillip Oster) writes:
  406. > How do you disable the cacheing of disk i/o to ram via program
  407. > control?
  408. > I remember reading that the Finder would turn off disk cacheing when it
  409. > did a file copy, because the copy would just flush anything useful in
  410. > the cache. The same article that said this described a way to turn the
  411. > cache on and off and query its current state so it could be restored,
  412. > but I don't remember where that article was. I searched the current
  413. > Developer's CD for "disk cache" without finding it.
  414. > I have a real reason, not just superstitious fear of the cache:  I'm
  415. > asking because I've written a driver for a SCSI scanner. If the cache
  416. > is too large, then when the application that calls the driver writes a
  417. > buffer of scan data to disk, the disk i/o takes so long that the
  418. > scanner hardware times out and locks up.
  419.  
  420. I think that Technote #81 is what you are looking for. I also have a rather
  421. mysterious note written in my copy that says to "set bit 5 of ioPosMode to
  422. inhibit caching." I don't know if this applies of PBRead, PBWrite, or both. Give
  423. it a shot.
  424.  
  425. - --
  426. Keith Rollin
  427. Phantom Programmer
  428. Taligent, Inc.
  429.  
  430.  
  431. ---------------------------
  432.  
  433. From: ozma@kuhub.cc.ukans.edu
  434. Subject: Booleans & SIZE in THINK C (not related)
  435. Date: 14 Jun 92 00:56:40 CDT
  436. Organization: University of Kansas Academic Computing Services
  437.  
  438. Two problems programming with THINK C (although THINK C isn't necessarily the
  439. problem - it't likely me).
  440.  
  441. I still can't rely on passing or returning Booleans in THINK C.  Like:
  442.  
  443.   Boolean CommandKeyIsDown (void)
  444.   {
  445.      /* GetKeys(), BitTst for Command Key Code, return result */
  446.   }
  447.  
  448. When I say:  if (CommandKeyIsDown()) {, I never get a TRUE condition.  Changing
  449. the Boolean to a char isn't reliable either.
  450.  
  451.   short CommandKeyIsDown (void)
  452.   {
  453.     /* same code with (short) casting of BitTst() */
  454.   }
  455.  
  456. The above works.  Why not char or Boolean?  Should these types be avoided as
  457. conditionals?  Sometimes as well, passing in a Boolean like:
  458.  
  459.   void CalculateScore (Boolean drawIt)
  460.   {
  461.     /* blah, blah, blah */
  462.   }
  463.  
  464. Doesn't work.  (This particular example isn't real and may differ some from the
  465. functions that I've found fail.)
  466.  
  467. My seconds problem is, why can't I increase the size (SIZE) allocated to my
  468. app?  I added a SIZE resource (maybe I shouldn't have), but in any event, when
  469. I try bumping it up to 2 megs (from 1 meg), THINK C doesn't give it the
  470. additional meg.  So, I bump the partition size up to 2 megs using THINK C's
  471. menus (what is it, the Project Type menu?) - this doesn't give me the 2 megs
  472. either.  Mind you, I have 17 megs on my machine.
  473.  
  474. If it's of any consequence, THINK C 5.02, System 7.0.1 (Tuned), IIsi.  If it's
  475. anything other than mindless stupidity on my part, I'll post responses. 
  476. Thanks.
  477.  
  478. john calhoun
  479.  
  480.  
  481. +++++++++++++++++++++++++++
  482.  
  483. From: ewylie@ocf.berkeley.edu (Elizabeth Wylie)
  484. Date: 14 Jun 1992 08:41:57 GMT
  485. Organization: U. C. Berkeley Open Computing Facility
  486.  
  487. > I still can't rely on passing or returning Booleans in THINK C. Like: 
  488. >   Boolean CommandKeyIsDown (void) 
  489. >   { 
  490. >      /* GetKeys(), BitTst for Command Key Code, return result */ 
  491. >   } 
  492. > When I say: if (CommandKeyIsDown()) {, I never get a TRUE condition.
  493. > Changing the Boolean to a char isn't reliable either.
  494.  
  495. There is one reason I can think of for this to fail:          
  496.  
  497. Boolean KeyDown ()
  498.  
  499. {
  500.   KeyMap    myKeys;
  501.  
  502.   GetKeys (myKeys);
  503.  
  504.   return (myKeys [whateverByte] & whateverBit);
  505. }
  506.  
  507. I dont know off hand what bit to check of the key map.  I do know that the
  508. above code evalutes to a long and is then truncated to a Boolean.  So, if you are testing bit 8 (for example) and that bit is set, the above test will evaluate to 0x100.  BUT A BOOLEAN IS ONE BYTE.  C knows this and truncates the result leaving you with 0x00.  If this is what you are doing, you should do the following:
  509.  
  510. if (myKeys [whateverByte] & whateverBit)
  511.   return (TRUE);
  512. else
  513.   return (FALSE);
  514.  
  515. Booleans are often thought of as being two bytes long, they are not.  They are
  516. padded to two bytes when used in structures so that every field is on an even
  517. byte boundry.                                  
  518.  
  519. As for passing Booleans, perhaps you are doing the same sort of thing-- passing
  520. a two byte value that gets truncated to zero.
  521.  
  522. - -Elizabeth
  523. .
  524.  
  525.  
  526. +++++++++++++++++++++++++++
  527.  
  528. From: keith@taligent.com (Keith Rollin)
  529. Date: 15 Jun 92 20:19:52 GMT
  530. Organization: Taligent
  531.  
  532. In article <11f0olINNp2o@agate.berkeley.edu>, ewylie@ocf.berkeley.edu (Elizabeth
  533. Wylie) writes:
  534. > > I still can't rely on passing or returning Booleans in THINK C. Like: 
  535. > > 
  536. > >   Boolean CommandKeyIsDown (void) 
  537. > >   { 
  538. > >      /* GetKeys(), BitTst for Command Key Code, return result */ 
  539. > >   } 
  540. > > 
  541. > > When I say: if (CommandKeyIsDown()) {, I never get a TRUE condition.
  542. > > Changing the Boolean to a char isn't reliable either.
  543. > There is one reason I can think of for this to fail:          
  544. > Boolean KeyDown ()
  545. > {
  546. >   KeyMap    myKeys;
  547. >   GetKeys (myKeys);
  548. >   return (myKeys [whateverByte] & whateverBit);
  549. > }
  550. > I dont know off hand what bit to check of the key map.  I do know that the
  551. > above code evalutes to a long and is then truncated to a Boolean.  So, if you
  552. are testing bit 8 (for example) and that bit is set, the above test will
  553. evaluate to 0x100.  BUT A BOOLEAN IS ONE BYTE.  C knows this and truncates the
  554. result leaving you with 0x00.  If this is what you are doing, you should do the
  555. following:
  556. > if (myKeys [whateverByte] & whateverBit)
  557. >   return (TRUE);
  558. > else
  559. >   return (FALSE);
  560. > Booleans are often thought of as being two bytes long, they are not.  They are
  561. > padded to two bytes when used in structures so that every field is on an even
  562. > byte boundry.                                  
  563. > As for passing Booleans, perhaps you are doing the same sort of thing--
  564. passing
  565. > a two byte value that gets truncated to zero.
  566. > -Elizabeth
  567.  
  568.  
  569. I agree. The following has worked fine for me with no problems ever:
  570.  
  571.  
  572. Boolean    CommandKeyIsDown()
  573. {
  574.     const short kCommandKey = 0x37;
  575.  
  576.     return KeyIsDown(kCommandKey);
  577. }
  578.  
  579.  
  580. Boolean    KeyIsDown(short keyCode)
  581. {
  582.     union {
  583.         KeyMap            asMap;
  584.         unsigned char    asBytes[16];
  585.     } myMap;
  586.  
  587.     GetKeys(myMap.asMap);
  588.     return ((myMap.asBytes[keyCode >> 3] >> (keyCode & 0x07)) & 1) != 0;
  589. }
  590.  
  591.  
  592. - --
  593. Keith Rollin
  594. Phantom Programmer
  595. Taligent, Inc.
  596.  
  597.  
  598. ---------------------------
  599.  
  600. From: dobrohoczkim@cc4.crl.aecl.ca
  601. Subject: Sys 7 popupMenuCDEFProc in 6.0.7
  602. Organization: AECL RESEARCH
  603. Date: Mon, 15 Jun 1992 18:11:13 GMT
  604.  
  605. I am writing a system 6.0.7 application that needs some popup menus. I know
  606. that a CDEF has been created for these beasts in systen 7 so I figured "Why
  607.  reinvent the wheel". I copied the CDEF from the system 7 disk (resedit) to
  608. my application. What happen is that I get the popupmenu title, box+dropshadow
  609. and downward pointing arrow BUT there is no text in the box. When I select
  610. the popupmenu the title correctly hilites but the menu doesn't popup. Tr.
  611. TrackControl returns a partcode of 1 or 0 depending if I release inside (1)
  612. or outside (0) the box. The control min,max,value and contrlData fields all
  613. contian the correct (as outlined in Inside the Mac VI) values after creation
  614. of the control.
  615.  
  616. Is there something special about the popupMenuCDEFProc that it will only
  617. work in system 7?
  618. Has anyone else tried using the CDEF in an earlier system?
  619.  
  620. Thanks for the help,
  621.  
  622. Michael Dobrohoczki
  623. Chalk River Laboratories
  624. Atomic Energy Canada Ltd.
  625.  
  626. +++++++++++++++++++++++++++
  627.  
  628. From: leonardr@ccs.itd.umich.edu
  629. Organization: Campus Computing Sites, University of Michigan-Ann Arbor
  630. Date: Tue, 16 Jun 92 07:08:11 GMT
  631.  
  632. In article <15JUN92.14111387@cc4.crl.aecl.ca> dobrohoczkim@cc4.crl.aecl.ca writes:
  633. >I am writing a system 6.0.7 application that needs some popup menus. I know
  634. >that a CDEF has been created for these beasts in systen 7 so I figured "Why
  635. > reinvent the wheel". I copied the CDEF from the system 7 disk (resedit) to
  636. >my application. What happen is that I get the popupmenu title, box+dropshadow
  637. >and downward pointing arrow BUT there is no text in the box. 
  638.  
  639. >Is there something special about the popupMenuCDEFProc that it will only
  640. >work in system 7?
  641. >Has anyone else tried using the CDEF in an earlier system?
  642. >
  643.     Although it is possible to make the popUpMenuCDEF to work with
  644. System 6, it wouldn't do you much good since you couldn't legally ship that
  645. CDEF with your software (unless you wnat to pay Apple $$ for the sofware
  646. license).  Another thing to keep in mind is that that CDEF will be updated in
  647. the future to support future System Software advances, and if you "borrow" it,
  648. you won't get them.
  649.  
  650.     I would suggest that you find one of the many freely available PopUp
  651. CDEF's which work with System's 6 & 7 and use that if the system one isn't
  652. avilable (it is availa under sys6 w/the CTB installed) otherwise use the
  653. System supplied one - you'll be MUCH better off.
  654.  
  655.  
  656. - -- 
  657. - -----------------------------------------------------------------------
  658. Leonard Rosenthol          Internet: leonardr@ccs.itd.umich.edu
  659. Director of Advanced Technology   AppleLink: MACgician
  660. Aladdin Systems, inc.          GEnie:     MACgician
  661.  
  662. ---------------------------
  663.  
  664. From: sdm7g@aemsun.med.Virginia.EDU (Steven D. Majewski)
  665. Subject: MPW shell crashes with Bus Error
  666. Organization: University of Virginia - Physiology Dept.
  667. Date: Mon, 15 Jun 1992 22:06:55 GMT
  668.  
  669.  
  670. MPW keeps crashing on me when trying to run a non-apple MPW tool. 
  671. ( At least Macsbug says that MPW is the current application, and 
  672.   not the tool. ) 
  673.  
  674. I'm running:
  675.     System 7.0.1
  676.     Mac IIci
  677.     Latest MPW from ETO#7
  678.  
  679. and I have tried with and without: 
  680.      32 bit addressing
  681.      virtual memory
  682.      virus protection
  683.      Macsbug & Discipline installed
  684.  
  685. And I've tried Latest MPW, and the MPW shells from MPW 3.2 & MPW QR7. 
  686.  
  687. The behaviour is similar ( at least without Macsbug installed, that or
  688. Discipline seems to have changed the appearance of the crash somewhat )
  689. to that described in the MPW ETO #7 Latest Shell Release Notes: 
  690.  
  691. Known Outstanding Bugs: 
  692.      ... 
  693.  * Under system 7, tools that attempt to bring up the Standard File 
  694.    dialog in the background will bring up an empty window and totally 
  695.    freeze the computer so that only a manual restart is possible. 
  696.     ... 
  697.  
  698. There is no solution suggested(*). I failed at getting either the previous
  699. of next version of MPW shell to do any better. I do not know that the 
  700. tool is, in fact, trying to bring up a Stand. File Dialog. I am able to
  701. get an error message on stderr from the tool if I leave out it's required
  702. parameters. 
  703.  
  704.  
  705.  
  706. With Macsbug installed, it gets a Bus Error: 
  707.  
  708.   Bus Error at 0024C8FA 'CODE 0001 069E Main'+07B2 
  709.   while reading byte from 0062F89C in Supervisor data space.
  710.  
  711. ( offending instruction is a MOVE.B    (A1)+,D3 
  712.   where A1 had the offending address ( now autoincremented to next ))
  713.  
  714. [ Actual addresses vary, of course. ] 
  715.  
  716.  
  717. Any clues or suggestions appreciated! 
  718.  
  719.  
  720. BTW: Is there any sort of internet connecttion to AppleLink and/or
  721. any official Bug reporting to Apple. Most of the phone/modem connections
  722. available to me are call-out only. 
  723.  
  724.  
  725. ======== "If you have a hammer, find a nail" - George Bush,'91  =========
  726.  Steven D. Majewski        University of Virginia Physiology Dept.
  727.  sdm7g@Virginia.EDU        Box 449 Health Sciences Center
  728.  Voice: (804)-982-0831/32    1300 Jefferson Park Avenue
  729.  FAX:   (804)-982-1616        Charlottesville, VA 22908
  730.  
  731.  
  732. +++++++++++++++++++++++++++
  733.  
  734. From: jackl@austin.apple.com (Jack Littleton)
  735. Date: Mon, 15 Jun 1992 23:38:05 GMT
  736. Organization: Apple Computer, Inc.
  737.  
  738. In article <1992Jun15.220655.19376@murdoch.acc.Virginia.EDU>, sdm7g@aemsun.med.Virginia.EDU (Steven D. Majewski) writes:
  739. > The behaviour is similar ( at least without Macsbug installed, that or
  740. > Discipline seems to have changed the appearance of the crash somewhat )
  741. > to that described in the MPW ETO #7 Latest Shell Release Notes: 
  742. > Known Outstanding Bugs: 
  743. >      ... 
  744. >  * Under system 7, tools that attempt to bring up the Standard File 
  745. >    dialog in the background will bring up an empty window and totally 
  746. >    freeze the computer so that only a manual restart is possible. 
  747. >     ... 
  748. > There is no solution suggested(*). I failed at getting either the previous
  749. > of next version of MPW shell to do any better. I do not know that the 
  750. > tool is, in fact, trying to bring up a Stand. File Dialog. I am able to
  751. > get an error message on stderr from the tool if I leave out it's required
  752. > parameters. 
  753. It's kind of hard to diagnose the problem without knowing what tool you're
  754. running, becuase if a tool running under the MPW shell causes [bus | address]
  755. errors, MacsBug states that the currently running application is the MPW
  756. Shell (which is the correct answer becuase tools are not apps and run in
  757. the Shell's heap).
  758.  
  759. I've deduced that the problem you may be talking about is the GetFileName
  760. tool, which did have some problems with freezing the machine in it's 3.2
  761. release, but was fixed in the 3.2.1 release.  Changing the Shell will not
  762. help; it's not doing anything wrong.
  763.  
  764. I could be wrong about this (the Shell may be doing something wrong), but
  765. I use it everyday (even Sundays!) and haven't had this problem since using
  766. a post-3.2 GetFileName.
  767.  
  768. - --
  769. Jack Littleton
  770. Developer Tools Engineering Group
  771. Apple Computer, Inc.
  772.  
  773. ---------------------------
  774.  
  775. From: mike@zorch.SF-Bay.ORG (Mike Smithwick)
  776. Subject: PopUp menus crash bigtime on Mac II and IIFX machines. Why?
  777. Organization: SF-Bay Public-Access Unix
  778. Date: Tue, 16 Jun 1992 02:02:58 GMT
  779.  
  780. []
  781.  
  782. I am trying to put the finishing touches on a commercial product, but
  783. have run across one of the nasty show-stopper bugs that I cannot
  784. recreate here at home. 
  785.  
  786. I was finally able to track down a machine out at the local NASA base
  787. which would crash on demand for me, and now I have all sorts of questions.
  788.  
  789. The situation is that a couple of my beta testers, both running IIfx
  790. machines were reporting that my popup menus would cause a system
  791. error #84, a menu-purge error. They would also get the same error
  792. when trying to use keyboard-equivalents bound to menus.
  793.  
  794. I tried this on one IIfx, and couldn't reproduce the problem. I finally
  795. tried it on a good ol' Mac II running 6.05 I think, and got the failure.
  796.  
  797. I finally tracked it down to the routine MenuKey() for the keyboard stuff
  798. and PopUpMenuSelect() for the popups. Trouble is, these fail ONLY for
  799. heirarchical menus. Option keys bound to normal root menuitems work fine.
  800. And in turn, the h-menus display fine for normal operations. Just these
  801. two operations fail. Anyone know of what might be happening?
  802.  
  803. Everything works great on Quadras to my dad's old Mac plus. I even
  804. tried it on a Powerbook 170 with no problems.
  805.  
  806.  
  807. mike
  808.  
  809. - -- 
  810. "There is no problem too big that can't be solved with high explosives"-Rush
  811.  
  812. Mike Smithwick - ames!zorch!mike
  813.  
  814.  
  815. +++++++++++++++++++++++++++
  816.  
  817. From: grobbins@Apple.COM (Grobbins)
  818. Date: 16 Jun 92 07:39:40 GMT
  819. Organization: Apple DTS
  820.  
  821. In article <1992Jun16.020258.10451@zorch.SF-Bay.ORG> mike@zorch.SF-Bay.ORG (Mike Smithwick) writes:
  822. >...
  823. >I finally tracked it down to the routine MenuKey() for the keyboard stuff
  824. >and PopUpMenuSelect() for the popups. Trouble is, these fail ONLY for
  825. >heirarchical menus. Option keys bound to normal root menuitems work fine.
  826. >And in turn, the h-menus display fine for normal operations. Just these
  827. >two operations fail. Anyone know of what might be happening?
  828. >
  829. >Everything works great on Quadras to my dad's old Mac plus. I even
  830. >tried it on a Powerbook 170 with no problems.
  831.  
  832. Yep, there is a bug on machines with older Mac II ROMs which makes
  833. MenuKey fail big time when it tries to match to pop-up items (I
  834. wasn't aware of a hierarchical menu problem, but they're siblings
  835. to pop-ups so it seems likely to be a manifestation of the same
  836. bug.)
  837.  
  838. A workaround is to manually match the menu key to items in
  839. pop-ups or hierarchicals; call MenuKey only if that fails
  840. to turn up a match (since MenuKey should be safe on main
  841. menus.)
  842.  
  843. This should be fixed under a future version of system software, but
  844. I have no idea when that will happen.
  845.  
  846. Any questions on this, please follow up via mail.
  847.  
  848. Grobbins            grobbins@apple.com
  849.  
  850. Usual disclaimers apply.
  851.  
  852. ---------------------------
  853.  
  854. End of C.S.M.P. Digest
  855. **********************
  856.